echo -e "Detecting Wireless interfaces on this device. . ."

# Get a list of wireless interfaces and create and array out of their names

IFACES=`iwconfig 2>&1 | grep "ESSID" | awk '{print $1}'`
IFACES_STRING=`echo -e $IFACES`
IFS=" "
IFACES_ARR=( $IFACES_STRING )

# Loop through every wireless interface name

j=1
for ((i=0; i<${#IFACES_ARR[@]}; i++))

do
#        Find the MAC address of the current interface

        GET_IFACE=${IFACES_ARR[$i]}
        GET_MAC=`ifconfig $GET_IFACE | grep "HWaddr" | awk '{print $5}'`

        STRCMP=`echo $GET_MAC`

        # Implement a hardware listener to get the driver detils of that interface

        if [ -n "$STRCMP" ]; then
        
                DRIVER_NAME=`lshw -C network | grep -B 7 $GET_MAC | grep "product"`
                VEND_NAME=`lshw -C network | grep -B 7 $GET_MAC | grep "vendor"`

                if [ -n "$DRIVER_NAME" ]
                then
                        if [ -n "$VEND_NAME" ]
                        then
                                echo -e "Wireless Detected! - "$GET_IFACE" - "${VEND_NAME:15}" "${DRIVER_NAME:16}""
                                echo -e "LAN_IF $GET_IFACE" > config/lan_setup.conf
				CONTAINS_ATHEROS=`echo -e $VEND_NAME | grep -i "ATHEROS" `
				if [ -z "$CONTAINS_ATHEROS"  ]; then
					echo -e "ATHEROS no" > config/atheros.conf
				else
					echo -e "ATHEROS yes" > config/atheros.conf
				fi
				break
			fi
                fi
        fi
done

